package com.yao.controller;

import com.yao.domain.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {

    //用户登录
    @RequestMapping("/login")
    public Object login(HttpServletRequest request){
        User user = new User();
        user.setId(1001);
        user.setName("zhangsan");
        request.getSession().setAttribute("user",user);
        return "登录成功 success";
    }

    //登录后才可以访问
    @RequestMapping("/center")
    public Object center(){
        return "see center message";
    }

    //不登陆也可以访问
    @RequestMapping("/out")
    public Object out(){
        return "out";
    }

    //用户未登录，但是访问了要登录才可以访问的数据，才回调到该路径
    @RequestMapping("/myError")
    public Object error(){
        return "error";
    }




}
